﻿Imports System
Imports NHibernate.Mapping.Attributes

<Serializable()> _
<[Class](Table:="SurvivorPicks")> _
Public Class PickObj
    Private myPickId As Integer
    Private myUsername As String
    Private myBracketRound As Integer?
    Private myIsWinner As Boolean?
    'Private myTeamId As Integer?

    <Id(0, Name:="PickId")> _
    <Generator(1, Class:="native")> _
    Public Overridable Property PickId() As Integer
        Get
            Return myPickId
        End Get
        Set(ByVal value As Integer)
            myPickId = value
        End Set
    End Property

    <[Property]()> _
    Public Overridable Property Username() As String
        Get
            Return myUsername
        End Get
        Set(ByVal value As String)
            myUsername = value
        End Set
    End Property

    <[Property]()> _
    Public Overridable Property BracketRound() As Nullable(Of Integer)
        Get
            Return myBracketRound
        End Get
        Set(ByVal value As Nullable(Of Integer))
            myBracketRound = value
        End Set
    End Property

    '<[Property]()> _
    'Public Overridable Property TeamId() As Nullable(Of Integer)
    '    Get
    '        Return myTeamId
    '    End Get
    '    Set(ByVal value As Nullable(Of Integer))
    '        myTeamId = value
    '    End Set
    'End Property

    Public Overridable ReadOnly Property TeamDisplay() As String
        Get
            If Me.Team Is Nothing Then
                Return ""
            Else
                Return Me.Team.TeamName
            End If
        End Get
    End Property

    Public Overridable ReadOnly Property TeamDisplayWithRegion() As String
        Get
            If Me.Team Is Nothing Then
                Return ""
            Else
                Return Me.Team.DisplayMember2
            End If
        End Get
    End Property

    <[Property]()> _
    Public Overridable Property IsWinner() As Nullable(Of Boolean)
        Get
            Return myIsWinner
        End Get
        Set(ByVal value As Nullable(Of Boolean))
            myIsWinner = value
        End Set
    End Property


    Private myTeam As TeamObj
    <ManyToOne(Column:="TeamId", ClassType:=GetType(TeamObj), Fetch:=FetchMode.Join)> _
    Public Overridable Property Team() As TeamObj
        Get
            Return myTeam
        End Get
        Set(ByVal value As TeamObj)
            myTeam = value
        End Set
    End Property

End Class
